<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var pFlag = true;
function formCheck2() {
	//id 중복관련 전송여부 (true : 전송불가, false : 전송)
	var form = window.document.join;
	
	if (!form.password.value) {	
		alert("패스워드를 넣으세요");
		form.password.focus();
		return false;
		
	}
	if (!form.password2.value) {
		alert("패스워드 재입력을 넣으세요");
		form.password2.focus();
		return false;
	}
	if (pFlag){
		alert("비밀번호가 일치하지 않습니다.");
		form.password2.focus();
		return false;
	}
	if (!form.name.value) {
		alert("이름을 넣으세요");
		form.name.focus();
		return false;
	}
	if (!form.birthday.value) {
		alert("생년월일을 넣으세요");
		form.birthday.focus();
		return false;
	}
	if (!form.seq.value) {
		alert("주소를 검색하세요");
		form.zipcode.focus();
		return false;
	}
	if (!form.email.value) {
		alert("이메일을 넣으세요");
		form.email.focus();
		return false;
	}
	if (!form.phoneNo.value) {
		alert("전화번호를 넣으세요");
		form.phoneNo.focus();
		return false;
	}
	
	document.join.submit();
}

function searchAddress() {
	window.open("/hansot/jsp/address_pop.jsp", "", "width=600,height=300");
}
function checkPassword() {
	var form = window.document.join;
	if (form.password.value != form.password2.value) {
		document.getElementById("pass_msg").innerHTML = "<font size='2' color='red'>비밀번호가 상이합니다.</font>";
		pFlag = true;
	} else {
		document.getElementById("pass_msg").innerHTML = "<font size='2' color='blue'>비밀번호가 적합합니다.</font>";
		pFlag = false;
	}
}
function question(){
	var flag = window.confirm("회원탈퇴 후회 없긔?");
	if(!flag){
		return false;
	}
}
</script>
</head>
<body>
<h2>회원정보 수정</h2>
<hr>
<form name="join" action="updateMember.do">
<input type="hidden" name="memberId" id="memberId" value="${sessionScope.login_info.memberId }">
		<input type="hidden" name="seq" id="seq" value="${sessionScope.login_info.seq}">
		<table>
			<tr>
				<td align="center">ID :</td>
				<td><input type="text" name="id" id="id" value="${sessionScope.login_info.memberId }" disabled="disabled"/></td>
			</tr>
			<tr>
				<td align="center">비밀번호 :</td>
				<td><input type="password" name="password" id="password"></td>
			</tr>
			<tr>
				<td align="center">비밀번호 재입력 :</td>
				<td><input type="password" name="password2"
					onkeyup="checkPassword();" id="password2"><span
					id='pass_msg'></span></td>
			</tr>
			<tr>
				<td align="center">이름 :</td>
				<td><input type="text" name="name" id="name" value="${sessionScope.login_info.name }"/></td>
			</tr>
			<tr>
				<td align="center">생년 월일 :</td>
				<td><input type="text" name="birthday" id="birthday" value="${sessionScope.login_info.birthday }"></td>
			</tr>
			<tr>
				<td align="center">주소 :</td>
				<td>
					<table>
						<tr>
							<td>우편번호 :</td>
							<td><input type="text" name="zipcode" style="width: 80px" value="${sessionScope.zipcode }" disabled="disabled">
								<input type="button" value="주소검색" onclick="searchAddress();">
							</td>
						</tr>
						<tr>
							<td>주소 :</td>
							<td><input type="text" name="address1" id="address1" value="${sessionScope.smAddress }"
								style="width: 300px" disabled="disabled">
							</td>
						</tr>
						<tr>
							<td>상세 주소 :</td>
							<td><input type="text" name="address" id="address" value="${sessionScope.login_info.address }"
								style="width: 300px"></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td align="center">e-mail :</td>
				<td><input type="text" name="email" id="email" value="${sessionScope.login_info.email }"></td>
			</tr>
			<tr>
				<td align="center">phone :</td>
				<td><input type="text" name="phoneNo" id="phoneNo" value="${sessionScope.login_info.phoneNo }"></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="button" onclick="formCheck2();" value="수정">
					<input type="reset" value="reset"><a href="memberDelete.do"><input type="button" value="회원탈퇴" onclick="return question();"></a></td>
			</tr>
		</table>
	</form>
</body>
</html>